|
STEP 3: Sourcing in the randomFromList Method
|
This example makes use of Music.randomFromList static method in exactly the same way as the previous example's randomFromList function, except that in this case we are relying on the fact that the static method is defined in the JavaScript extension file "music-object-x-dynamic.js".
Try reloading this page several times. It should behave in exactly the same way as the previous example where the randomFromList function was explicitly pasted into the HTML document. The JavaScript is shown in the source code listing below. Once again, place this JavaScript towards the end of your HTML file, in the spot where you'd like the random music file to be embedded. Follow the same guidelines for using the randomFromList function as outlined in the previous example.
| |
<SCRIPT SRC="music-object.js"></SCRIPT> <SCRIPT SRC="music-object-x-dynamic.js"></SCRIPT> <SCRIPT LANGUAGE=JavaScript><!-- // fileToPlay = Music.randomFromList ( 'ambient', 'classical', 'house', 'jungle', 'lounge', 'modern-rock', 'sfx-medley', 'techno', 'trance' ); Music.magicEmbed ( 'SRC="music/' + fileToPlay + '.rmf" ' + 'AUTOSTART=TRUE ' + 'DISPLAY=SONG ' + 'MODE=INFO ' + 'LOOP=FALSE ' + 'VOLUME=100' ); // --></SCRIPT> |